﻿using System.Collections.Generic;
using System.Collections.ObjectModel;


namespace OpenLightGroup.Common
{
    public static class ObservableCollectionExtensions
    {

        /// <summary>
        /// Adds the list of items to the current ObservalbeCollection.
        /// </summary>
        /// <typeparam name="T">The type of item to add.</typeparam>
        /// <param name="collection">The current observable collection.</param>
        /// <param name="items">The items to add.</param>
        public static void AddRange<T>(this ObservableCollection<T> collection, IEnumerable<T> items)
        {
            foreach (var item in items)
                collection.Add(item);

        }

        /// <summary>
        /// Creates an observable collection from any IEnumerable
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="items">The items.</param>
        /// <returns></returns>
        public static ObservableCollection<T> ToObservableCollection<T>(this IEnumerable<T> items)
        {
            var output = new ObservableCollection<T>();

            output.AddRange(items);

            return output;

        }
    }
}
